//
//  GMInfoController.m
//  Teecloud
//
//  Created by PC on 2018/7/6.
//  Copyright © 2018年 小熊. All rights reserved.
//

#import "GMInfoController.h"
#import "XZChangePwdVC.h"
#import "XZBindPhoneNumVC.h"
#import "XZResManagementVC.h"
#import "XZModifyNameVC.h"
#import "XZAddressVC.h"
#import "CYLTabBarController.h"
//Model
#import "GMRowItem.h"
#import "GMGroupItem.h"
#import "GMPersonInfo.h"
#import "XZInfoModel.h"

//View
#import "XZChooseSexView.h"
#import "GMInfoIconCell.h"
#import "GMMyselfSecondCell.h"
#import "GMChoseVC.h"
@interface GMInfoController () <UITableViewDelegate,UITableViewDataSource,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong)XZChooseSexView *sexView;
@property (nonatomic, strong) XZInfoModel *model;
@property (nonatomic, strong) NSMutableArray *dataSource;

@end
static NSString *IconIdentifier = @"Icon";
static NSString *identifier = @"GMMyselfSecondCell";
@implementation GMInfoController
#pragma mark - Lifecycle
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self getData];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"个人资料";
    self.view.backgroundColor = kWhiteColor;
}
#pragma mark - getData
- (void)getData{//用户信息数据
    NSDictionary *dict= @{
                          @"from":FROM_IOS,
                          @"busiOrgId":[XGMArchiverTools cacheForKey:BUSIORGID],
                          @"loginFinger":[XGMArchiverTools cacheForKey:USER_identifierNumber],
                          @"userId":[XGMArchiverTools cacheForKey:USER_UserId]
                          };
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    __weak typeof(self)weakSelf = self;
    [HJNetwork POSTWithURL:[NSString stringWithFormat:@"ajax-api.ashx?$c=TeeyunApp&$m=GetUserInfo&$v=%@",VERSION] parameters:dict cachePolicy:HJCachePolicyIgnoreCache callback:^(id responseObject, NSError *error) {
        [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
        if (!error) {
            if ([[responseObject objectForKey:RESULT_NAME_Success] boolValue]) {
                NSLog(@"%@",responseObject);
                NSDictionary *dataInfo = [responseObject objectForKey:RESULT_NAME_Data];
                XZInfoModel *infoModel = [XZInfoModel mj_objectWithKeyValues:dataInfo];
                weakSelf.model = infoModel;
                
                [self.dataSource removeAllObjects];
                
                [weakSelf setOneSectionSource:infoModel];
                [weakSelf setTwoSectionSource:infoModel];
                [weakSelf setThreeSectionSource:infoModel];
                [weakSelf setFourSectionSource:infoModel];
                [weakSelf setFiveSectionSource];
                
            }else{
                /**显示错误信息*/
                [weakSelf setOneSectionSource:nil];
                [weakSelf setTwoSectionSource:nil];
                [weakSelf setThreeSectionSource:nil];
                [weakSelf setFourSectionSource:nil];
                [weakSelf setFiveSectionSource];
                [MBProgressHUD showErrorOrSuc:[responseObject objectForKey:RESULT_NAME_Message] toView:weakSelf.view];
            }
            
        }else{
            [weakSelf setOneSectionSource:nil];
            [weakSelf setTwoSectionSource:nil];
            [weakSelf setThreeSectionSource:nil];
            [weakSelf setFourSectionSource:nil];
            [weakSelf setFiveSectionSource];
            XZLog(@"%@",error);
        }
    }];
}
/*第一列的值的组装*/
- (void)setOneSectionSource:(XZInfoModel *)info{
    GMRowItem *firstItem = [GMRowItem itemWithTitle:@"我的头像"];
    firstItem.subTitle = @"头像";
    
    GMRowItem *secondItem = [GMRowItem itemWithTitle:@"用户名"];
    secondItem.subTitle = info.LoginName;
    
    GMRowItem *threeItem = [GMRowItem itemWithTitle:@"绑定手机号"];
    threeItem.subTitle = info.MobileCode;
    
    GMRowItem *fourthItem = [GMRowItem itemWithTitle:@"姓名"];
    fourthItem.subTitle = info.Name;
    
    GMRowItem *fiveItem = [GMRowItem itemWithTitle:@"性别"];
    fiveItem.subTitle = info.Sex;
    
    
    GMRowItem *sixItem = [GMRowItem itemWithTitle:@"地区"];
    sixItem.subTitle = info.RegionName;
    
    
    GMGroupItem *group = [[GMGroupItem alloc]init];
    group.items = @[firstItem,secondItem,threeItem,fourthItem,fiveItem,sixItem];
    
    [self.dataSource addObject:group];
    
}
/*第三列的值的组装*/
- (void)setTwoSectionSource:(XZInfoModel *)info{
    /*后面的subtitle是用什么来赋值？*/
    GMRowItem *firstItem = [GMRowItem itemWithTitle:@"我的应用"];
    firstItem.subTitle = [XGMArchiverTools cacheForKey:BUSName];
    GMGroupItem *group = [[GMGroupItem alloc]init];
    group.items = @[firstItem];
    [self.dataSource addObject:group];
}
/*第二列的值的组装*/
- (void)setThreeSectionSource:(XZInfoModel *)info{
    /*后面的subtitle是用什么来赋值？*/
    GMRowItem *firstItem = [GMRowItem itemWithTitle:@"付费资源管理"];
    NSInteger payCount = [info.PayResCount integerValue];
    firstItem.subTitle = [NSString stringWithFormat:@"%ld个",payCount];
    
    GMGroupItem *group = [[GMGroupItem alloc]init];
    group.items = @[firstItem];
    [self.dataSource addObject:group];
}

/*第四列的值的组装*/
- (void)setFourSectionSource:(XZInfoModel *)info{
    GMRowItem *firstItem = [GMRowItem itemWithTitle:@"等级"];
    firstItem.subTitle = info.GradeName;
    firstItem.isHiddeArrow = YES;
    
    GMRowItem *secondItem = [GMRowItem itemWithTitle:@"积分"];
    secondItem.isHiddeArrow = YES;
    if (info != nil) {
        secondItem.subTitle = [NSString stringWithFormat:@"%@",info.Score];
    }
    
    GMRowItem *threeItem = [GMRowItem itemWithTitle:@"学币"];
    threeItem.isHiddeArrow = YES;
    if (info != nil) {
        threeItem.subTitle = [NSString stringWithFormat:@"%@",info.Coin];
    }
    
    GMGroupItem *group = [[GMGroupItem alloc]init];
    group.items = @[firstItem,secondItem,threeItem];
    
    [self.dataSource addObject:group];
    
}
/*第五列的值的组装*/
- (void)setFiveSectionSource{
    GMRowItem *firstItem = [GMRowItem itemWithTitle:@"修改密码"];
    
    GMGroupItem *group = [[GMGroupItem alloc]init];
    group.items = @[firstItem];
    
    [self.dataSource addObject:group];
    
    [self.tableView reloadData];
    
}
#pragma mark - TableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.dataSource.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    GMGroupItem *groupItem = self.dataSource[section];
    return groupItem.items.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            GMInfoIconCell *iconCell = [tableView dequeueReusableCellWithIdentifier:IconIdentifier];
            iconCell.selectionStyle = UITableViewCellSelectionStyleNone;
            //给图片赋值
            [iconCell.iconImageView sd_setImageWithURL:[NSURL URLWithString:self.model.HeadUrl] placeholderImage:[UIImage imageNamed:@"headPortrait"]];
            return iconCell;
            
        }
    }
   
    //防止复用
    GMMyselfSecondCell * cell = [tableView cellForRowAtIndexPath:indexPath];
    //解决xib复用数据混乱问题
    if (nil == cell) {
        cell= (GMMyselfSecondCell *)[[[NSBundle  mainBundle]  loadNibNamed:@"GMMyselfSecondCell" owner:self options:nil]  lastObject];
    }else{
        //删除cell的所有子视图
        while ([cell.contentView.subviews lastObject] != nil)
        {
            [(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview];
        }
    }
    
    
    if (indexPath.section == 2) {//等级
        if (indexPath.row == 0) {
            cell.levelView.hidden = false;
        }
    }
    GMGroupItem *group =self.dataSource[indexPath.section];
    GMRowItem *row = group.items[indexPath.row];
    cell.item = row;
    cell.model = self.model.GradeIconCount;
    return cell;
}
#pragma mark - TableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return section == 0 ? 0.0001 : 8;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return section == 4 ? 100 : 0.0001;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    if (section == 4) {
        UIView *footView = [[UIView alloc]init];
        footView.backgroundColor = [UIColor colorWithHexString:@"DDDDDD" andAlpha:1];
        UIButton *logoutButton = [UIButton buttonWithType:UIButtonTypeCustom];
        logoutButton.frame = CGRectMake(10, 30, DEVICE_WIDTH - 20, 40);
        [logoutButton setTitle:@"退出登录" forState:UIControlStateNormal];
        [logoutButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [logoutButton setBackgroundColor:[UIColor redColor]];
        logoutButton.layer.cornerRadius = 10.0;
        [logoutButton addTarget:self action:@selector(logoutButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [footView addSubview:logoutButton];
        return footView;
    }
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:true];
    //XZChangePwdVC
    switch (indexPath.section) {
        case 0:{
            switch (indexPath.row) {
                case 0:{//我的头像
                    [self updateUserImageView];
                }
                    break;
                case 1:{//用户名
                    [self inputLoginName];
                }
                    break;
                case 2:{//绑定手机号
                    XZBindPhoneNumVC *bindPhoneNumVC = [[XZBindPhoneNumVC alloc]init];
                    [self.navigationController pushViewController:bindPhoneNumVC animated:true];
                    
                }
                    break;
                case 3:{//姓名
                    XZModifyNameVC *modifyNameVC = [[XZModifyNameVC alloc]init];
                    modifyNameVC.name =self.model.Name;
                    [self.navigationController pushViewController:modifyNameVC animated:true];
                }
                    break;
                case 4:{//性别
                    [self choosSex];
                    
                }
                    break;
                case 5:{//地区
                    XZAddressVC *addressVC = [[XZAddressVC alloc]init];
                    addressVC.type = @"SCUCESS";
                    [self.navigationController pushViewController:addressVC animated:true];
                }
                    break;
                case 6:{//我的班级
                    
                }
                default:
                    break;
            }
        }
            break;
            
        case 1:{
            switch (indexPath.row) {
                case 0:{
                    //替换应用单位
                    GMChoseVC *resManagementVC = [[GMChoseVC alloc]init];
                    [self.navigationController pushViewController:resManagementVC animated:true];
                }
                    break;
                default:
                    break;
            }
        }
            break;
        case 2:{
            switch (indexPath.row) {
                case 0:{
                    //付费资源管理
                    XZResManagementVC *resManagementVC = [[XZResManagementVC alloc]init];
                    [self.navigationController pushViewController:resManagementVC animated:true];
                }
                    break;
                default:
                    break;
            }
        }
            break;
            
        case 3:{
            switch (indexPath.row) {
                case 0:{
                    //等级
                    
                }
                    break;
                case 1:{
                    //积分
                    
                }
                    break;
                case 2:{
                    //学币
                    
                }
                    break;
                default:
                    break;
            }
        }
            break;
            
        case 4:{
            switch (indexPath.row) {
                case 0:{
                    //修改密码
                    XZChangePwdVC *changePwd = [[XZChangePwdVC alloc]init];
                    [self.navigationController pushViewController:changePwd animated:true];
                }
                    
                default:
                    break;
            }
        }
            break;
            
        default:
            break;
    }
}
//上传头像
- (void)updateUserImageView{
    //显示弹出框列表选择
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil
                                                                   message:nil
                                                            preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel
                                                         handler:^(UIAlertAction * action) {
                                                             //响应事件
                                                             NSLog(@"action = %@", action);
                                                         }];
    UIAlertAction* manAction = [UIAlertAction actionWithTitle:@"相机" style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction * action) {
                                                          [self choseImageWithTypeCameraTypePhotoLibrary:UIImagePickerControllerSourceTypeCamera];
                                                      }];
    UIAlertAction* womanAction = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault
                                                        handler:^(UIAlertAction * action) {
                                                            //响应事件
                                                            [self choseImageWithTypeCameraTypePhotoLibrary:UIImagePickerControllerSourceTypePhotoLibrary];
                                                        }];
    [alert addAction:cancelAction];
    [alert addAction:manAction];
    [alert addAction:womanAction];
    [self presentViewController:alert animated:YES completion:nil];
}

-(void)choseImageWithTypeCameraTypePhotoLibrary:(UIImagePickerControllerSourceType)type{
    
    UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate =self;
    imagePicker.sourceType = type;
    imagePicker.allowsEditing = YES;
    imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    imagePicker.allowsEditing =YES;
    [self presentViewController:imagePicker animated:YES completion:^{
        
    }];
}
#pragma mark 选择照片上传服务器
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
    NSMutableArray *arr = [[NSMutableArray alloc] init];
    [arr addObject:image];
    NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
    formatter.dateFormat = @"yyyyMMddHHmmss";
    NSString * str = [formatter stringFromDate:[NSDate date]];
    NSString *fileName = [NSString stringWithFormat:@"%@.png",str];
    NSDictionary *dict= @{@"from":FROM_IOS,
                          @"busiOrgId":[XGMArchiverTools cacheForKey:BUSIORGID],
                          @"loginFinger":[XGMArchiverTools cacheForKey:USER_identifierNumber],
                          @"userId":[XGMArchiverTools cacheForKey:USER_UserId],
                          @"fileType":@"user-head"
                          };
    [MBProgressHUD showErrorOrSuc:@"正在上传" toView:self.view];
    [HJNetwork uploadImageURL:[NSString stringWithFormat:@"/ajax-api.ashx?$c=TeeyunApp&$m=UploadFile&$v=%@",VERSION] parameters:dict images:arr name:@"file" fileName:fileName mimeType:@"image/jpeg" progress:^(NSProgress *progress) {
        
    } callback:^(id responseObject, NSError *error) {
        if (!error) {
            if ([[responseObject objectForKey:RESULT_NAME_Success] boolValue]){
                [MBProgressHUD showErrorOrSuc:@"上传成功" toView:self.view];
                NSDictionary *dataInfo = [responseObject objectForKey:RESULT_NAME_Data];
                NSString *FileUrl = dataInfo[@"FileUrl"];
                //更新用户头像
                [self updateUserInfo:@"HeadUrl" fieldValue:FileUrl];
            }else{
                /**显示错误信息*/
                [MBProgressHUD showErrorOrSuc:[responseObject objectForKey:RESULT_NAME_Message] toView:self.view];
            }
        }
    }];
    [picker dismissViewControllerAnimated:YES completion:^{
        
    }];
}
//更新用户信息
- (void)updateUserInfo:(NSString *)fieldName fieldValue:(NSString *)fieldValue{
    NSDictionary *dict= @{@"from":FROM_IOS,
                          @"busiOrgId":[XGMArchiverTools cacheForKey:BUSIORGID],
                          @"loginFinger":[XGMArchiverTools cacheForKey:USER_identifierNumber],
                          @"newUserId":[XGMArchiverTools cacheForKey:USER_UserId],
                          @"fieldName":fieldName,
                          @"fieldValue":fieldValue,
                          @"userId":[XGMArchiverTools cacheForKey:USER_UserId]
                          };
    
    __weak typeof(self)weakSelf = self;
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    [HJNetwork POSTWithURL:[NSString stringWithFormat:@"/ajax-api.ashx?$c=TeeyunApp&$m=UpdateUserInfo&$v=%@",VERSION] parameters:dict cachePolicy:HJCachePolicyIgnoreCache callback:^(id responseObject, NSError *error) {
        [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
        if (!error) {
            if ([[responseObject objectForKey:RESULT_NAME_Success] boolValue]) {
                //重新拉取用户信息
                [weakSelf getData];
            }else{
                [MBProgressHUD showErrorOrSuc:[responseObject objectForKey:RESULT_NAME_Message] toView:weakSelf.view];
            }
            
        }else{
             [MBProgressHUD showErrorOrSuc:@"网络异常" toView:weakSelf.view];
        }
    }];
    
}
//更换用户名
- (void)inputLoginName{
    kWeakObject(self)
    //创建一个弹框
    UIAlertController *addAlertVC = [UIAlertController alertControllerWithTitle:@"请输入您的用户名" message:nil preferredStyle:UIAlertControllerStyleAlert];
    
    //创建两个textFiled输入框
    [addAlertVC addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        if (!kIsEmptyString(weakself.model.LoginName)) {
             textField.text = weakself.model.LoginName;
        }else{
             textField.placeholder = @"请输入用户名";
        }
       
    }];
    //创建取消事件(按钮)
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    //添加 取消事件 到 弹窗界面
    [addAlertVC addAction:cancelAction];
    //创建 确认按钮(事件) 并添加到弹窗界面
    __weak typeof(self) weakSelf= self;
    UIAlertAction *confirmAction =[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
        NSString *loginName = addAlertVC.textFields.firstObject.text;
        [weakSelf updateUserInfo:@"LoginName" fieldValue:loginName];
    }];
    [addAlertVC addAction:confirmAction];
    //模态显示一个弹框  注意: UIAlterController只能通过模态形式进行弹出,不能使用push
    [self.navigationController presentViewController:addAlertVC animated:NO completion:nil];
}
//选择性别
- (void)choosSex{
    //显示弹出框列表选择
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"选择性别"
                                                                   message:nil
                                                            preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel
                                                         handler:^(UIAlertAction * action) {
                                                             XZLog(@"action = %@", action);
                                                         }];
    UIAlertAction* manAction = [UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction * action) {
                                                          //响应事件
                                                           [self updateUserInfo:@"Sex" fieldValue:action.title];
                                                      }];
    UIAlertAction* womanAction = [UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault
                                                        handler:^(UIAlertAction * action) {
                                                            //响应事件
                                                            [self updateUserInfo:@"Sex" fieldValue:action.title];
                                                        }];
    [alert addAction:cancelAction];
    [alert addAction:manAction];
    [alert addAction:womanAction];
    [self presentViewController:alert animated:YES completion:nil];
}
#pragma mark - Logout
- (void)logoutButtonClick{
    NSDictionary *dict= @{
                          @"from":FROM_IOS,
                          @"busiOrgId":[XGMArchiverTools cacheForKey:BUSIORGID],
                          @"userId":[XGMArchiverTools cacheForKey:USER_UserId],
                          @"loginFinger":[XGMArchiverTools cacheForKey:USER_identifierNumber]
                          };
    __weak typeof(self)weakSelf = self;
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    [HJNetwork POSTWithURL:[NSString stringWithFormat:@"/ajax-api.ashx?$c=TeeyunApp&$m=Logout&$v=%@",VERSION] parameters:dict cachePolicy:HJCachePolicyIgnoreCache callback:^(id responseObject, NSError *error) {
        [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
        if (!error) {
            if ([[responseObject objectForKey:RESULT_NAME_Success] boolValue]) {
                [MBProgressHUD showErrorOrSuc:@"退出成功" toView:weakSelf.view];
                //清除账号跟密码 UserId
                [XGMArchiverTools removeForKey:USER_UserId];
                [XGMArchiverTools removeForKey:USERPASSWD];
                dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);
                dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                    [self cyl_popSelectTabBarChildViewControllerAtIndex:0 completion:^(__kindof UIViewController *selectedTabBarChildViewController) {
                       
                    }];
//                    [self.navigationController popToRootViewControllerAnimated:YES];
                    /*延迟两秒之后发送通知，刷新主控制器*/
//                    kPostNotificationWithName(KNOTIFICATION_LOGIN);
                });
            }else{
                [MBProgressHUD showErrorOrSuc:[responseObject objectForKey:RESULT_NAME_Message] toView:weakSelf.view];
            }
        }else{
            [MBProgressHUD showErrorOrSuc:@"网络异常" toView:weakSelf.view];
        }
    }];
    
}


#pragma mark - getter

- (UITableView *)tableView{
    if (_tableView == nil) {
        CGRect rect = CGRectMake(0,0, DEVICE_WIDTH, DEVICE_HEIGHT-64);
        _tableView = [[UITableView alloc] initWithFrame:rect style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor colorWithHexString:@"DDDDDD" andAlpha:1];
        _tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0.0001)];
        //注册cell
        _tableView.tableFooterView = [UIView new];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GMInfoIconCell class]) bundle:nil] forCellReuseIdentifier:IconIdentifier];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GMMyselfSecondCell class]) bundle:nil] forCellReuseIdentifier:identifier];
        _tableView.showsVerticalScrollIndicator = false;
        _tableView.showsHorizontalScrollIndicator = false;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self.view addSubview:_tableView];
    }
    return _tableView;
}
- (NSMutableArray *)dataSource{
    if (!_dataSource) {
        _dataSource = [[NSMutableArray alloc]init];
    }
    return _dataSource;
}

@end
